height = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]
import sys

left = []  # 左边界
mid = []  # 底
right = []  # 右边界
max_num = 0


def main(a):
    left_num = 0
    mid_num = 0
    right_num = 0
    for i in range(a, len(height)):  # 遍历数组
        if height[i] > left_num:
            left_num = height[i]
            for j in range(i + 1, len(height)):
                if height[j] > right_num:
                    right_num = height[j]
                    for k in range(i + 1, j):
                        if height[k] < min(left_num, right_num):
                            global max_num
                            max_num = max_num + min(left_num, right_num) - height[k]
                    print(max_num)
                    return main(j)


main(0)
